﻿#ifndef TCPCODEC_H
#define TCPCODEC_H

#include <qobject.h>
#include "ObjAutoInject.h"
#include "TcpCodecBase.h"
#include <qtimer.h>
#include <qhash.h>

class TcpIOer;
class ReadMEMSDataCodec_Client;
class DataHandler;
class TcpCodec :  public QObject,public ObjAutoInject,public TcpCodecBase
{
  Q_OBJECT
private://property
  QHash<unsigned char/*dataType*/,TcpCodecBase*> codecMap;
private://dependency
  ReadMEMSDataCodec_Client* readMEMSDataCodec_Server=Q_NULLPTR;
  TcpIOer* tcpIOer=Q_NULLPTR;
  DataHandler* dataHandler=Q_NULLPTR;
public:
  explicit TcpCodec();
  virtual ~TcpCodec();
public:
  void code(DataPackage_TcpCodec* dataPackage_TcpCodec);
  void code(uchar type,QByteArray data);
  virtual void decode(DataPackage_TcpCodec* dataPackageInfo_User)override;
  void addToCodecMap(uchar type,TcpCodecBase* tcpCodecBase);
private slots:
  void slot_decode(QByteArray data);
public://geter and seter
  TcpIOer* getTcpIOer();
  TcpCodec* setTcpIOer(TcpIOer* tcpIOer);
public:
  virtual void objectAutoInjection(QHash<QString,QObject*>* objMap)override;
};

#endif // TCPCODEC_H
